<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>筋斗云案例</title>
    <style>
        body {
            padding: 0;
            margin: 0;
        }

        .box {
            margin: 0 auto;
        }

        a {
            text-decoration: none;
            color: white;
        }

        .box {
            width: 700px;
            height: 35px;
            background-color: #369;
        }

        li {
            width: 65px;
            height: 35px;
            list-style-type: none;
            text-align: center;
            float: left;
            margin-right: 10px;
            line-height: 35px;
        }

        .cloud  {
            float: left;
            width: 65px;
            height: 35px;
            background-color: pink;
            z-index: -1;
        }
        /* .clouds{
            float: left;
            z-index: 2;
            background: url(精灵图.PNG) repeat ;
            opacity: .01;
            background-size: contain;
            width: 65px;
            height: 35px;
            background-color: red;

        } */
    </style>
</head>

<body>
    <div class="box">
        <span class="cloud"></span>
        <ul>
            <li class="current"><a href="">首页新闻</a></li>
            <li><a href="">师资力量</a></li>
            <li><a href="">活动策划</a></li>
            <li><a href="">企业文化</a></li>
            <li><a href="">招聘信息</a></li>
            <li><a href="">公司简介</a></li>
            <li><a href="">上海校区</a></li>
            <li><a href="">广州校区</a></li>
        </ul>
    </div>
    <script src="animate.js"></script>
    <script>
        var box = document.querySelector('.box')
        var cloud = document.querySelector('.cloud')
        var lis = box.querySelectorAll('li');
        var current = 0;
        for (var i = 0; i < lis.length; i++) {
            lis[i].addEventListener('mouseenter',function(){
                animate(cloud,this.offsetLeft)
            });
            lis[i].addEventListener('mouseleave',function(){
                animate(cloud,current)
            });
            lis[i].addEventListener('click',function(){
                current = this.offsetLeft;
            });
            
        }
    </script>
</body>

</html>